package com.example.task;

import com.example.domain.MeetingApplication;
import com.example.mapper.MeetingApplicationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * 定时任务类，定时处理订单状态
 */
@Component
public class ApplicationTask {
    @Autowired
    MeetingApplicationMapper meetingApplicationMapper;


    @Scheduled(cron = "0 0/10 * * * ?")//每十分钟触发一次
    public void TimeoutApplication(){
        // 获取当前时间
        Date currentTime = new Date();
        List<MeetingApplication> list =  meetingApplicationMapper.getOutTime(0,currentTime);
        for (MeetingApplication meetingApplication : list) {
            meetingApplication.setStatus( 1L );
            meetingApplicationMapper.updateMeetingApplication( meetingApplication );
        }
    }
}
